package com.hanserwei.springbootlearn.mapper;

import com.hanserwei.springbootlearn.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper {

    @Select("select r.id,role from user_role as ur left join role as r on ur.role_id = r.id where ur.user_id=#{id} ")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "role", property = "role")
    })
    List<Role> selectUserRoles(Integer id);
}
